<div class="da-list-wrap">
  <div class="da-content-banner">
    <d-breadcrumb>
      <d-breadcrumb-item><a routerLink="/">{{ 'process.breadcrumb.home' | translate }}</a></d-breadcrumb-item>
      <d-breadcrumb-item>{{ 'process.breadcrumb.mom' | translate }}</d-breadcrumb-item>
    </d-breadcrumb>
  </div>
  <div class="da-content-wrapper">
        <div class="da-list-container">
          <div class="da-list-header">
                <div class="d-input">
                  <div class="inputIn">
                    <input dTextInput style="width: 180px;"  [error]="false" placeholder="输入物料编码/物料名称" [(ngModel)]="SearchTerm">
                    <d-select style="width: 180px;" [options]="optionsStatus" placeholder="MOM状态" name="IsApproval" [(ngModel)]="IsApproval" class="me-2"></d-select>
                  </div>
                  <div class="d-submit">
                    <d-button id="primaryBtn" style="margin-left: 8px" (btnClick)="filter()"><i class="icon icon-filter-o me-2"></i>查询</d-button>
                  <d-button bsStyle="common" (btnClick)="reset()"> <i class="icon icon-refresh me-2"></i>重置</d-button>
                  </div>
                </div>
                <div class="btn-group">
                  <d-button bsStyle="primary"routerLink="/pages/process/mom/add-mom" ><i class="icon icon-add me-2"></i>MOM搭建</d-button>
                  <d-button bsStyle="danger" (btnClick)="Deletes()" ><i class="icon icon-delete me-2"></i>删除</d-button>
                </div>
          </div>
          <div class="list-content">
            <d-data-table [dataSource]="tabledata" [lazy]="true" [scrollable]="true" [fixHeader]="true" [tableWidthConfig]="tableWidthConfig"  [tableOverflowType]="'auto'" [scrollable]="true"  [resizeable]="true" (checkAllChange)="getCheckedRows()" (rowCheckChange)="getCheckedRows()">
              <thead dTableHead [checkable]="true">
                <tr dTableRow>
                  <th dHeadCell [fixedLeft]="'80px'">
                    <span>操作</span>
                  </th>
                  <th dHeadCell [fixedRight]="colOption.fixedRight" *ngFor="let colOption of dataTableOptions.columns">{{ colOption.header }}</th>
                </tr>
              </thead>
              <tbody dTableBody>
                <ng-template let-rowItem="rowItem" let-rowIndex="rowIndex" let-nestedIndex="nestedIndex">
                  <tr dTableRow>
                    <td dTableCell [fixedLeft]="'0'">
                      <d-checkbox [disabled]="false" [showAnimation]="true" [ngModelOptions]="{ standalone: true }"
                      [ngModel]="rowItem.$checked"
                      dTooltip
                      [halfchecked]="rowItem.$halfChecked"
                      [showGlowStyle]="false"  (ngModelChange)="onRowCheckChange($event, rowIndex, nestedIndex, rowItem)"
                      ></d-checkbox>
                    </td>
                    <td dTableCell [rowItem]="rowItem" [fixedLeft]="'80px'">
                      <span><a class="devui-link" [class.disabled]="rowItem?.isApproval" (click)="edit(rowItem?.momId)">维护</a></span>
                      <span class="ms-3"><a class="devui-link-danger" (click)="Delete(rowItem?.momId)" [class.disabled]="rowItem?.isApproval">删除</a></span>
                      <span class="ms-3"><a class="devui-link" (click)="preview(rowItem)">预览</a></span>
                      <span class="ms-3"><a class="devui-link" (click)="Approval(rowItem?.momId)" [class.disabled]="rowItem?.isApproval">核准</a></span>
                      <span class="ms-3"><a class="devui-link" (click)="UnApproval(rowItem?.momId)" [class.disabled]="rowItem?.isApproval"[class.disabled]="!rowItem?.isApproval">反核准</a></span>
                    </td>
                    <td dTableCell  [rowItem]="rowItem"
                    [field]="'type'">
                      <span dTooltip [content]="rowItem?.partName">{{ rowItem?.partName}}</span>
                    </td>
                    <td dTableCell  [rowItem]="rowItem"
                    [field]="'type'">
                      <span dTooltip [content]="rowItem?.partNum">{{ rowItem?.partNum}}</span>
                    </td>
                    <td dTableCell  [rowItem]="rowItem"
                    [field]="'enabled'">
                    <span dTooltip [content]="rowItem?.version">{{rowItem?.version}}</span>
                    </td>
                    <td dTableCell  [rowItem]="rowItem"
                    [field]="'enabled'">
                    <span dTooltip [content]="rowItem?.technologyRouteName">{{rowItem?.technologyRouteName}}</span>
                    </td>
                    <td dTableCell  [rowItem]="rowItem"
                    [field]="'enabled'">
                    <span dTooltip [content]="rowItem?.startDate | date:'yyyy-MM-dd HH:mm'">{{rowItem?.startDate | date:'yyyy-MM-dd HH:mm'}}</span>
                    </td>
                    <td dTableCell  [rowItem]="rowItem"
                    [field]="'enabled'">
                    <span dTooltip [content]="rowItem?.endDate | date:'yyyy-MM-dd HH:mm'">{{rowItem?.endDate | date:'yyyy-MM-dd HH:mm'}}</span>
                    </td>
                    <td dTableCell  [rowItem]="rowItem">
                      <span (click)="openDrawer(rowItem.momId)"><a class="devui-link">查看</a></span>
                    </td>
                    <td dTableCell  [rowItem]="rowItem"
                    [field]="'enabled'" [fixedRight]="'0px'">
                    <span dTooltip [content]="rowItem?.isApproval | isApproval"><d-tag [tag]=" rowItem?.isApproval | isApproval" [labelStyle]="rowItem?.isApproval" ></d-tag></span>
                    </td>
                  </tr>
                </ng-template>
              </tbody>
            </d-data-table>
          </div>
         <div class="page-footer">
            <div>
              <p>已选 <span class="underline">{{checkedIds.length}}</span> 条
                <a (click)="cleared()" class="clear">清空</a>
              </p>
            </div>
            <d-pagination
            [size]="'sm'"
            [canViewTotal]="true"
            [canChangePageSize]="true"
            [canJumpPage]="true"
            [maxItems]="5"
            [total]="this.pager.total"
            [pageSizeOptions]="this.pageSizeOptions"
            [(pageSize)]="pager.pageSize"
            [(pageIndex)]="pager.pageIndex"
            (pageIndexChange)="pageIndexChange($event)"
            (pageSizeChange)="pageSizeChange($event)"
            >
            </d-pagination>
          </div>
        </div>
  </div>
</div>
<d-toast [value]="msgs" [life]="2000" [styleClass]="'custom-class'" [style]="{ left: '50%',top:'10px' }"></d-toast>
